<?php
namespace App\Http\Controllers\Wechat;

use App\Http\Controllers\Controller;
use App\WechatHandlers\EventHandler;
use App\WechatHandlers\TextMessageHandler;
use EasyWeChat\Kernel\Messages\Message;
use Overtrue\LaravelWeChat\Facade;

/**
 * Class OfficialController
 * @package App\Http\Controllers\Wechat
 * @author zjw
 * 公众号
 */
class OfficialController extends Controller{
    /**
     * @return \Symfony\Component\HttpFoundation\Response
     * @throws \EasyWeChat\Kernel\Exceptions\BadRequestException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
     * 微信公众号入口
     */
    public function index(){
        $app = Facade::officialAccount();
        $app->server->push(TextMessageHandler::class, Message::TEXT);
        $app->server->push(EventHandler::class, Message::EVENT);
        $response = $app->server->serve();
        return $response;
    }
}
